public class Test {
    public static void main(String[] args) {
        //认识枚举
        A a1 = A.X;
        System.out.println(a1);
        //1. 枚举的构造器是私有的,不能对外创建对象
//        A a = new A();

        //枚举的第一行都是常量,记住的是枚举的对象
        A a2 = A.Y;

        //枚举提供了一些额外的API
        //拿到全部对象
        A[] as = A.values();
        for (int i = 0; i < as.length; i++) {
            System.out.println(as[i]);
        }

        //拿到某个对象
        A a3 = A.valueOf("Z");
        System.out.println(a3.name());  //名称
        System.out.println(a3.ordinal()); //索引
    }
}
